#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 5000010;
int f[N], sum[N];
int main()
{
	int n, p; cin >> n >> p;
	for(int i=1; i <=n;i++)
	{
		int a; cin >> a;
		f[i] += a, f[i+1] -=a; 
	 } 
	 for(int i = 1; i <= p; i++)
	 {
	 	int l, r, a; 
	 	cin >> l >> r >> a;
	 	f[l] += a, f[r+1] -= a;
	 }
	 int m = 0x3f3f3f3f;
	 for(int i=1; i <=n; i++)
	 {
	 	f[i] += f[i-1];
	 	m = min(m, f[i]);
	 }
	 cout << m <<  endl;
 } 